package com.example.live.adapter

import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.example.common.entity.BannerEntity
import com.example.image.R
import com.example.image.glide.GlideImgLoader
import com.youth.banner.adapter.BannerAdapter

class GoodsBannerAdapter (data:List<String>):BannerAdapter<String,GoodsBannerAdapter.BannerViewHolder>(data){
    inner class BannerViewHolder(val imageView: ImageView): RecyclerView.ViewHolder(imageView)

    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): BannerViewHolder {
        val imageView = ImageView(parent!!.context)
        imageView.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
        imageView.scaleType = ImageView.ScaleType.CENTER_CROP
        return BannerViewHolder(imageView)
    }

    override fun onBindView(holder: BannerViewHolder?, data: String?, position: Int, size: Int) {
        Glide.with(holder!!.imageView.context)
            .load(data)
            .error(R.drawable.ic_yu_icon)
            .placeholder(R.drawable.ic_yu_icon)
            .skipMemoryCache(false)
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
            .into(holder.imageView)
    }

}